Instead, use the widget's context.
HICON prev_hicon;
#endif
GtkIconHelper *icon_helper;
- GtkStyleContext *context;
cairo_surface_t *surface;
GtkWidget *widget;
GdkPixbuf *pixbuf;
if (widget == NULL)
return;
- context = gtk_widget_get_style_context (widget);
round_size = round_pixel_size (widget, priv->size);
icon_helper = _gtk_icon_helper_new (widget);
_gtk_icon_helper_set_definition (icon_helper, priv->image_def);
_gtk_icon_helper_set_icon_size (icon_helper, GTK_ICON_SIZE_SMALL_TOOLBAR);
_gtk_icon_helper_set_pixel_size (icon_helper, round_size);
- surface = gtk_icon_helper_load_surface (icon_helper, context, 1);
+ surface = gtk_icon_helper_load_surface (icon_helper, 1);
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, round_size, round_size);
cairo_surface_destroy (surface);
if (!_gtk_icon_helper_get_is_empty (icon_helper))
_gtk_icon_helper_get_size (icon_helper,
- gtk_widget_get_style_context (widget),
&pixbuf_width, &pixbuf_height);
g_object_unref (icon_helper);
icon_helper = create_icon_helper (cellpixbuf, widget);
_gtk_icon_helper_draw (icon_helper,
- context, cr,
+ cr,
pix_rect.x, pix_rect.y);
g_object_unref (icon_helper);
state = gtk_style_context_get_state (context);
gtk_style_context_get_padding (context, state, &padding);
- _gtk_icon_helper_get_size (icon_info->icon_helper, context,
+ _gtk_icon_helper_get_size (icon_info->icon_helper,
&width, NULL);
gtk_style_context_restore (context);
context = gtk_widget_get_style_context (widget);
gtk_style_context_save_to_node (context, icon_info->css_node);
- _gtk_icon_helper_get_size (icon_info->icon_helper, context,
+ _gtk_icon_helper_get_size (icon_info->icon_helper,
&pix_width, &pix_height);
state = gtk_style_context_get_state (context);
gtk_style_context_get_padding (context, state, &padding);
y = MAX (0, (height - pix_height) / 2);
_gtk_icon_helper_draw (icon_info->icon_helper,
- context, cr,
+ cr,
x, y);
gtk_style_context_restore (context);
context = gtk_widget_get_style_context (GTK_WIDGET (entry));
gtk_style_context_save_to_node (context, icon_info->css_node);
- _gtk_icon_helper_get_size (icon_info->icon_helper, context, &width, &height);
- surface = gtk_icon_helper_load_surface (icon_info->icon_helper,
- context,
- 1);
+ _gtk_icon_helper_get_size (icon_info->icon_helper, &width, &height);
+ surface = gtk_icon_helper_load_surface (icon_info->icon_helper, 1);
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
cairo_surface_t *
gtk_icon_helper_load_surface (GtkIconHelper *self,
- GtkStyleContext *context,
int scale)
{
cairo_surface_t *surface;
+ GtkStyleContext *context;
GtkIconSet *icon_set;
GIcon *gicon;
+ context = gtk_widget_get_style_context (self->priv->owner);
+
switch (gtk_image_definition_get_storage_type (self->priv->def))
{
case GTK_IMAGE_SURFACE:
scale = gtk_widget_get_scale_factor (self->priv->owner);
- self->priv->rendered_surface = gtk_icon_helper_load_surface (self, context, scale);
+ self->priv->rendered_surface = gtk_icon_helper_load_surface (self, scale);
}
void
_gtk_icon_helper_get_size (GtkIconHelper *self,
- GtkStyleContext *context,
gint *width_out,
gint *height_out)
{
+ GtkStyleContext *context;
gint width, height, scale;
+ context = gtk_widget_get_style_context (self->priv->owner);
width = height = 0;
/* Certain kinds of images are easy to calculate the size for, these
void
_gtk_icon_helper_draw (GtkIconHelper *self,
- GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y)
{
+ GtkStyleContext *context = gtk_widget_get_style_context (self->priv->owner);
+
gtk_icon_helper_ensure_surface (self, context);
if (self->priv->rendered_surface != NULL)
const gchar *_gtk_icon_helper_get_icon_name (GtkIconHelper *self);
cairo_surface_t *gtk_icon_helper_load_surface (GtkIconHelper *self,
- GtkStyleContext *context,
int scale);
void _gtk_icon_helper_get_size (GtkIconHelper *self,
- GtkStyleContext *context,
gint *width_out,
gint *height_out);
void _gtk_icon_helper_draw (GtkIconHelper *self,
- GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y);
GtkImagePrivate *priv = image->priv;
gint width, height;
GtkBorder border;
- GtkStyleContext *context;
- context = gtk_widget_get_style_context (GTK_WIDGET (image));
- _gtk_icon_helper_get_size (priv->icon_helper, context, &width, &height);
+ _gtk_icon_helper_get_size (priv->icon_helper, &width, &height);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
_gtk_misc_get_padding_and_border (GTK_MISC (image), &border);
G_GNUC_END_IGNORE_DEPRECATIONS
else
{
_gtk_icon_helper_draw (priv->icon_helper,
- context, cr,
+ cr,
x, y);
}
_gtk_icon_helper_set_icon_name (icon_helper, "list-add-symbolic", GTK_ICON_SIZE_MENU);
}
- _gtk_icon_helper_get_size (icon_helper, context, &icon_width, &icon_height);
+ _gtk_icon_helper_get_size (icon_helper, &icon_width, &icon_height);
gtk_render_background (context, cr, 0, 0, width, height);
gtk_render_frame (context, cr, 0, 0, width, height);
x = floor ((width - icon_width) / 2.0);
y = floor ((height - icon_height) / 2.0);
- _gtk_icon_helper_draw (icon_helper, context, cr, x, y);
+ _gtk_icon_helper_draw (icon_helper, cr, x, y);
cairo_restore (cr);
gtk_style_context_restore (context);